package com.mikao.dao;


import com.mikao.entity.GoodsEvaluate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author kenny
 */
public interface EvaluateDao extends JpaRepository<GoodsEvaluate, Long>, JpaSpecificationExecutor {

    /**
     * 根据商品ID查找商品评价
     *
     * @param id ID
     * @return list
     */
    List<GoodsEvaluate> findAllByGoodsIdOrderByCreateTimeDesc(Long id);

    @Query("select count(e) from GoodsEvaluate e ")
    Integer findAllCount();

    @Query("select count(e) from GoodsEvaluate e where (e.level=1 or e.level=2)")
    Integer findGoodCount();
}
